import styles from "./index.module.scss";
import { Pagination } from "antd";
import { useDispatch, useSelector } from "react-redux";
import closeBtn from "@/assets/public/close-btn.png";
import closeBtnLight from "@/assets/public/close-btn-light.png";
import searchBtn from "@/assets/public/icon-search.png";
import { setLayers } from "@/store";
import SelectProjectModel from "@/component/selectProjectModel";

export default function Model(props) {
  const dispatch = useDispatch();
  const { name } = props;
  const layers = useSelector((state) => {
    return state.layers;
  });
  const theme = useSelector((state) => {
    return state.theme;
  });
  const handleClose = () => {
    dispatch(
      setLayers({
        query: {},
        name: "",
        other: {},
      })
    );
  };

  const getValue = (value) => {
    console.log(value);
  };

  return (
    <div className={styles.model}>
      <header className={styles.header}>
      {theme ? (
          <img
            style={{
              width: "20px",
              height: "22px",
            }}
            onClick={handleClose}
            src={closeBtnLight}
            alt="加载中..."
          />
        ) : (
          <img
            style={{
              width: "20px",
              height: "22px",
            }}
            onClick={handleClose}
            src={closeBtn}
            alt="加载中..."
          />
        )}
        <span className={styles.title}>{name}</span>
      </header>
      <div className={styles.inputContainer}>
        <SelectProjectModel getSelectValue={getValue.bind(this)} />
        <img className={styles.searchBtn} src={searchBtn} alt="加载中..." />
      </div>
      <div className={styles.total}>
        <div className={styles.totalItem}>
          <div className={styles.totalVal}>34,681</div>
          <div className={styles.totalTitle}>差旅费计划金额总计</div>
        </div>
        <div className={styles.totalItem}>
          <div className={styles.totalVal}>34,681</div>
          <div className={styles.totalTitle}>差旅费实际金额总计</div>
        </div>
        <div className={styles.totalItem}>
          <div className={styles.totalVal}>34,681</div>
          <div className={styles.totalTitle}>会务费计划金额总计</div>
        </div>
        <div className={styles.totalItem}>
          <div className={styles.totalVal}>34,681</div>
          <div className={styles.totalTitle}>会务费实际金额总计</div>
        </div>
      </div>
      <div className={styles.searchBox}>
        <div className={styles.listHeader}>
          <div className={styles.listItem}>借款负责人</div>
          <div className={styles.listItem}>一级项目名称</div>
          <div className={styles.listItem}>二级项目名称</div>
          <div className={styles.listItem}>差旅费计划金额</div>
          <div className={styles.listItem}>差旅费实际金额</div>
          <div className={styles.listItem}>会务费计划金额</div>
          <div className={styles.listItem}>会务费实际金额</div>
          <div className={styles.listItem}>月份</div>
        </div>
        {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((item) => {
          return (
            <div className={styles.list} key={item}>
              <div className={styles.listItem}>
                <span className="text-overflow">李四</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">一级项目名称</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">二级项目名称</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">56,123.02</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">56,123.02</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">56,123.02</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">56,123.02</span>
              </div>
              <div className={styles.listItem}>
                <span className="text-overflow">5月</span>
              </div>
            </div>
          );
        })}
      </div>
      <div className={styles.pagination}>
        <Pagination
          total={805}
          showTotal={(total) => `共 ${total} 条`}
          defaultPageSize={20}
          defaultCurrent={1}
        />
      </div>
    </div>
  );
}
